<template>
  <div>
    <el-drawer
      class="detail"
      title="盘点结果抽检导出"
      style="height: 27%;top: 20%;left: 40%;width: 83%;left: -20%;"
      :visible="true"
      @close="onClose"
    >
      <el-form :model="queryParams" ref="queryForm" style="margin-left: 10%">
        <el-form-item label="地区：" style="width: 50%;">
          <el-select v-model="area" placeholder="地区" clearable size="small" style="width: 120px">
            <el-option v-for="dict in areaOptions" :key="dict.value" :label="dict.name" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="库区：" style="width: 50%;margin-left: 50%;margin-top: -12%;">
          <el-select v-model="area" placeholder="地区" clearable size="small" style="width: 120px">
            <el-option v-for="dict in warehouseOptions" :key="dict.value" :label="dict.name" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="比例："style="width: 35%;">
          <el-input style="width: 50%"></el-input>
        </el-form-item>
        <el-form-item label="时间：" style="width: 65%;margin-left: 35%;margin-top: -12%;">
          <el-date-picker v-model="daterangeCreateTime" size="small" value-format="yyyy-MM-dd" style="width: 65%"
                          type="daterange" range-separator="-" start-placeholder="起始日期" end-placeholder="截止日期"></el-date-picker>
        </el-form-item>
<!--        <el-form-item>-->
<!--          <el-select v-model="area" placeholder="地区" clearable size="small" style="width: 120px">-->
<!--            <el-option v-for="dict in areaOptions" :key="dict.value" :label="dict.name" :value="dict.value" />-->
<!--          </el-select>-->
<!--          <el-select v-model="area" placeholder="库区" clearable size="small" style="width: 120px">-->
<!--            <el-option v-for="dict in warehouseOptions" :key="dict.value" :label="dict.name" :value="dict.value" />-->
<!--          </el-select>-->
<!--          <el-date-picker v-model="daterangeCreateTime" size="small" style="margin-left: 20px;width: 240px" value-format="yyyy-MM-dd"-->
<!--                          type="daterange" range-separator="-" start-placeholder="创建起始日期" end-placeholder="截止日期"></el-date-picker>-->
<!--        </el-form-item>-->
        <el-form-item>
          <el-button type="warning" icon="el-icon-refresh" size="mini" @click="openExport">导出</el-button>
          <el-button type="error" icon="el-icon-refresh" size="mini" @click="onClose">取消</el-button>
        </el-form-item>
      </el-form>
    </el-drawer>
  </div>
</template>

<script>
export default {
  name: "resultCheckExport",
  data(){
    return {
      area: '全部',
      areaOptions:[
        {value: '全部',name:'全部'},
        {value: '市直',name:'市直'},
        {value: '三元',name:'三元'},
        {value: '永安',name:'永安'},
        {value: '泰宁',name:'泰宁'},
        {value: '尤溪',name:'尤溪'},
        {value: '大田',name:'大田'},
        {value: '清流',name:'清流'},
        {value: '明溪',name:'明溪'},
        {value: '沙县',name:'沙县'},
        {value: '将乐',name:'将乐'},
        {value: '宁化',name:'宁化'},
        {value: '建宁',name:'建宁'},
        {value: '三钢',name:'三钢'}
      ],
      warehouseOptions:[
        {value: '全部',name:'全部'},
        {value: '普通物品区',name:'普通物品区'},
        {value: '电子设备区',name:'电子设备区'},
      ],
      daterangeCreateTime: [],
      params:{},
    }
  },
  methods:{
    onClose() {
      this.$emit('close')
    },
    openExport(){
      if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
        this.params["beginCreateTime"] = this.daterangeCreateTime[0];
        this.params["endCreateTime"] = this.daterangeCreateTime[1];
      }
      let data ={}
      if(this.area == '全部'){
        data = {
          params: this.params
        }
      }else{
        data = {
          areaName: this.area, params: this.params
        }
      }
      let startTime = this.params["beginCreateTime"].replaceAll('-','')
      let endTime = this.params["endCreateTime"].replaceAll('-','')
      this.download('wms/inventoryPlan/getInventoryPlanExport',data, `盘点结果_${this.area}_${startTime}-${endTime}.xlsx`)

    }
  }
}
</script>

<style scoped>

</style>
